<template>
  <div>
    <el-row>
      <el-col :span="20">
        <el-form :model="searchForm" inline @submit.native.prevent>
          <el-form-item>
            <el-input
              v-model="searchForm.fuzzy"
              style="width:250px"
              placeholder="项目名称/委托单位/合同编号"
              clearable
              @keyup.enter.native="handleSearch"
            />
          </el-form-item>
          <!--          <el-form-item label="合同编号:">-->
          <!--            <el-input v-model="searchForm.contCode" style="width:180px" placeholder="合同编号" />-->
          <!--          </el-form-item>-->
          <!--          <el-form-item label="项目名称:">-->
          <!--            <el-input v-model="searchForm.projectName" style="width:180px" placeholder="项目名称" />-->
          <!--          </el-form-item>-->
          <el-form-item>
            <el-button
              type="primary"
              class="iconfont icon-chaxun1"
              @click="handleSearch"
            >
              查询</el-button
            >
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="4" class="search-right">
        <el-button type="text" icon="el-icon-refresh" @click="handleSearch"
          >刷新</el-button
        >
      </el-col>
    </el-row>

    <el-table
      :data="taskData"
      stripe
      border
      highlight-current-row
      :header-cell-style="{ background: '#ECF3FC' }"
    >
      <template slot="empty">
        <div class="table_empty">
          <div class="empty_tips">
            <span>
              暂无任务信息
            </span>
          </div>
        </div>
      </template>
      <el-table-column type="index" width="50" label="序号" align="center" />
      <el-table-column
        prop="contCode"
        label="合同编号"
        width="185px"
        align="center"
      />
      <el-table-column prop="consignorName" label="受检单位" align="center" />
      <el-table-column
        prop="projectName"
        label="项目名称"
        min-width="120px"
        align="center"
      />
      <el-table-column prop="offerPlanVosOne" label="计划名称" align="center">
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              {{ element.planName }}
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="offerPlanVosTwo" label="监测频次" align="center">
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              {{ element.checkFreq }}
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="offerPlanVosThree" label="计划次数" align="center">
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              {{ element.scheduleTimes }}
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column
        prop="offerPlanVosFour"
        label="已执行次数"
        align="center"
      >
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              {{ element.scheduledTimes }}
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column
        prop="offerPlanVosFive"
        label="上次调度时间"
        align="center"
      >
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              {{ element.lastScheduleDate }}
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="offerPlanVosSix" label="计划状态" align="center">
        <div slot-scope="{ row }">
          <div v-for="element in row.offerPlanVos">
            <div
              style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;"
            >
              <span
                v-if="element.enableStatus === '1'"
                style="color: green;font-weight: bold"
                >启用</span
              >
              <span
                v-if="element.enableStatus === '2'"
                style="color: red;font-weight: bold"
                >暂停</span
              >
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column label="操作" align="center" width="250px">
        <template slot-scope="{ row }">
          <el-button
            v-if="row.scheduleFlag === '0'"
            type="text"
            @click="handleScheduler(row)"
          >
            创建新任务</el-button
          >
          <div class="erc-divider-vertical" v-if="row.scheduleFlag === '0'" />
          <el-button
            type="text"
            style="margin-left: 0px;"
            @click="handleDetail(row)"
          >
            已创建任务</el-button
          >
          <div class="erc-divider-vertical" />
          <el-dropdown>
            <span class="el-dropdown-link"> 更多<i class="el-icon-arrow-down el-icon--right" /> </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <el-button
                  v-if="row.scheduleFlag === '1'"
                  type="text"
                  @click="handleUpdateScheduler(row)"
                >
                  编辑新任务</el-button
                ></el-dropdown-item
              >
              <el-dropdown-item>
                <el-button type="text" @click="stopsSchedulesTasks(row.taskId)">
                  暂停项目</el-button
                ></el-dropdown-item
              >
              <el-dropdown-item>
                <el-button
                  type="text"
                  @click="deletesSchedulesTasks(row.taskId)"
                >
                  删除项目</el-button
                ></el-dropdown-item
              >
              <el-dropdown-item>
                <el-button type="text" @click="addPlanInfoOne(row)"
                  >新增计划</el-button
                ></el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <div style="float: right">
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"
      />
    </div>

    <!-- <el-dialog :title="taskTitle + ' 任务详情'" :visible.sync="taskVisible" center width="70%">
      <el-row>
        <el-col :span="12">
          <span>合同编号: {{ taskForm.contCode }}</span>
        </el-col>
        <el-col :span="12">
          <span>报价单号: {{ taskForm.offerId }}</span>
        </el-col>
      </el-row>
      <table class="info-table-new" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td style="background: #f5f5f5;">项目名称:</td>
          <td>{{ taskForm.projectName }}</td>
          <td style="background: #f5f5f5;">委托单位:</td>
          <td>{{ taskForm.consignorName }}</td>
        </tr>
        <tr>
          <td style="background: #f5f5f5;">委托联系人:</td>
          <td>{{ taskForm.consignorLinker }} </td>
          <td style="background: #f5f5f5;">委托联系人方式:</td>
          <td>{{ taskForm.consignorLinkerPhone }}</td>
        </tr>
        <tr>
          <td colspan="4" style="text-align: left;padding-left:15px;">
            检测内容:
          </td>
        </tr>
        <tr>
          <td colspan="4" style="text-align: left;padding-left:15px;">
            <el-row v-for="(item, index) in factorData" :key="index">
              <el-col :span="24" style="font-weight: bolder">{{ item.secdClassName + ':' }}</el-col>
              <el-col v-for="el in item.factList" :key="el.id" :span="24">
                {{ el.factorPoint + '（'+ el.dayCount +'*'+ el.frequency+'）: ' }}{{ el.showFactName }} <span v-if="el.fbFlag==='1'" style="color: red;"> (分包)</span>
              </el-col>
            </el-row>
          </td>
        </tr>
      </table>

    </el-dialog> -->

    <el-dialog
      :title="titleOne"
      :visible.sync="taskSedVisible"
      width="80%"
      center
      top="5vh"
      :close-on-click-modal="false"
    >
      <el-form
        ref="offerDisForm"
        :model="offerDisForm"
        :rules="OfferDisRules"
        label-width="130px"
      >
        <el-card shadow="never">
          <div slot="header" class="clearfix">
            <span slot="label">
              任务基础信息<i class="el-input__icon " />
            </span>
          </div>
          <el-row :gutter="10">
            <el-col :span="8" style="margin-left: 35px;">
              <el-form-item label="合同编号:">
                <el-input v-model="currentRow.contCode" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="14">
              <el-form-item label="项目名称:">
                <el-input v-model="currentRow.projectName" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="8" style="margin-left: 35px;">
              <el-form-item label="委托单位:">
                <el-input v-model="offerDisForm.consignorName" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item prop="consignorLinker" label="委托联系人:">
                <el-input
                  v-model="offerDisForm.consignorLinker"
                  placeholder="委托联系人"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item prop="consignorLinkerPhone" label="委托联系人电话:">
                <el-input
                  v-model="offerDisForm.consignorLinkerPhone"
                  placeholder="委托联系人电话"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="8" style="margin-left: 35px;">
              <el-form-item prop="inspectionName" label="受检单位:">
                <el-input
                  v-model="offerDisForm.inspectionName"
                  placeholder="受检单位"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item prop="inspectionLinker" label="受检联系人:">
                <el-input
                  v-model="offerDisForm.inspectionLinker"
                  placeholder="受检联系人"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item
                prop="inspectionLinkerPhone"
                label="受检联系人电话:"
              >
                <el-input
                  v-model="offerDisForm.inspectionLinkerPhone"
                  placeholder="受检联系人电话"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14" style="margin-left: 35px;">
              <el-form-item prop="projectAddress" label="项目地址:">
                <div style="width: 100%;">
                  <el-select
                    v-model="offerDisForm.province"
                    placeholder="请选择省"
                    style="width: 33%;"
                    @change="getSubRegionByRegionCode('cityArray', $event)"
                  >
                    <el-option
                      v-for="item in provinceArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"
                    />
                  </el-select>
                  <el-select
                    v-model="offerDisForm.city"
                    placeholder="请选择市"
                    style="width: 33%;"
                    @change="getSubRegionByRegionCode('areaArray', $event)"
                  >
                    <el-option
                      v-for="item in cityArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"
                    />
                  </el-select>
                  <el-select
                    v-model="offerDisForm.county"
                    style="width: 33%;"
                    placeholder="请选择区"
                  >
                    <el-option
                      v-for="item in areaArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"
                    />
                  </el-select>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-input
                v-model="offerDisForm.projectAddress"
                placeholder="请录入详细地址"
                style="width: 100%;"
              />
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="8" style="float:left" v-if="offerDisForm.checkType !== '1'">
              <el-form-item prop="startDate" :rules="offerDisForm.checkType === '0' ? OfferDisRules.startDate : []">
                <span style="margin-left: -119px;color: #101010;">
                  <span style="color: red;">*</span>&nbsp;现场采样约定日期
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="现场采样日期会在采样任务单中展示，若约定的日期有变动，请线下手动更改，系统不做强制日期限制，仅做任务进度提示"
                  >
                    <svg-icon
                      slot="reference"
                      icon-class="help"
                      style="font-size:16px"
                    />
                  </el-popover>
                  :
                </span>
                <el-date-picker
                  v-model="offerDisForm.startDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="开始日期"
                  style="width: 78%;"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" style="float:right">
              <el-form-item prop="endDate">
                <span style="margin-left: -190px;color: #101010;">
                  <span style="color: red;">*</span>&nbsp;客户要求领取报告日期
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="以客户要求领取报告的日期计，若客户没有要求，可自行填写，系统不做强制日期限制，仅做任务进度提示"
                  >
                    <svg-icon
                      slot="reference"
                      icon-class="help"
                      style="font-size:16px"
                    />
                  </el-popover>
                  :
                </span>
                <el-date-picker
                  v-model="offerDisForm.endDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="结束日期"
                  style="width: 78%;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <!--任务单号自动生成-->
          <el-row :gutter="10">
            <el-col :span="8" style="margin-left: 35px;">
              <el-form-item prop="jobId" label="任务单号:">
                <el-input v-if="!jobSwitch" :disabled="titleOne==='编辑新任务'" v-model="offerDisForm.jobId" placeholder="任务单号" style="width: 100%;"
                          onKeyUp="value=value.replace(/[\W]/g,'')" maxlength="14" />
                <el-input v-if="jobSwitch" disabled v-model="offerDisForm.jobId" placeholder="任务单号" style="width: 100%;"/>
              </el-form-item>
            </el-col>
            <el-col :span="8" style="margin-left: -120px;">
              <el-form-item>
                <el-switch v-model="jobSwitch"
                           :disabled="titleOne==='编辑新任务'"
                           active-text="自动生成"
                           active-color="#11b95c"
                           inactive-color="#909399ad"
                           @change="changeJobSwitch"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="22" style="margin-left: 35px;">
              <el-form-item prop="checkGoal">
                <span slot="label">
                  检测目的
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="检测目的的内容会在最终的检测报告中展示"
                  >
                    <svg-icon
                      slot="reference"
                      icon-class="help"
                      style="font-size:16px"
                    />
                  </el-popover>
                  :
                </span>
                <el-input
                  v-model="offerDisForm.checkGoal"
                  placeholder="检测目的"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="22" style="margin-left: 35px;">
              <el-form-item label="备注:">
                <el-input
                  v-model="offerDisForm.jobRemark"
                  placeholder="备注"
                  style="width: 100%;"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card title="" shadow="never" style="margin-top:10px">
          <div slot="header" class="clearfix">
            <span slot="label">
              选择待调度计划<i class="el-input__icon " />
            </span>

            <!--            <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="addPlanInfoOne">新增计划</el-button>-->
          </div>
          <el-table
            ref="multipleTable"
            :data="planTaskData"
            stripe
            highlight-current-row
            :header-cell-style="{ background: '#ECF3FC' }"
            border
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              width="50"
              :selectable="checkSelectable"
              align="center"
            />
            <el-table-column
              type="index"
              width="50"
              label="序号"
              align="center"
            />
            <el-table-column prop="planName" label="计划名称" align="center" />
            <el-table-column prop="checkFreq" label="监测频次" align="center" />
            <el-table-column
              prop="checkFactorCnt"
              label="检测因子数"
              align="center"
            />
            <el-table-column
              prop="scheduleTimes"
              label="计划次数"
              align="center"
            />
            <el-table-column
              prop="scheduledTimes"
              label="已执行次数"
              align="center"
            />
            <el-table-column
              prop="lastScheduleDate"
              label="上次调度时间"
              align="center"
            />
            <el-table-column
              prop="checkFactorCnt"
              label="计划状态"
              align="center"
            >
              <template slot-scope="{ row }">
                <span
                  v-if="row.enableStatus === '1'"
                  style="color: green;font-weight: bold"
                  >启用</span
                >
                <span
                  v-if="row.enableStatus === '2'"
                  style="color: red;font-weight: bold"
                  >暂停</span
                >
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="200">
              <template slot-scope="{ row }">
                <el-button type="text" @click="checkPlanDetail(row)"
                  >查看</el-button
                >
                <el-button type="text" @click="plansUpdate(row)"
                  >修改</el-button
                >
                <el-button
                  v-if="row.enableStatus === '1'"
                  type="text"
                  @click="enablesOrStopssOfferPlan(row.offerPlanId, false)"
                  >暂停</el-button
                >
                <el-button
                  v-if="row.enableStatus === '2'"
                  type="text"
                  @click="enablesOrStopssOfferPlan(row.offerPlanId, true)"
                  >开启</el-button
                >
                <el-button
                  type="text"
                  @click="deleteOfferPlans(row.offerPlanId)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button style="width: 90px;" @click="taskSedVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          style="width: 90px;"
          :disabled="multipleSelection.length === 0"
          @click="handlePreStep"
          >下一步</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      append-to-body
      title="检测因子"
      :visible.sync="planFactorVisible"
      width="70%"
    >
      <el-table :data="planFactorDetails" border stripe height="450">
        <el-table-column type="index" width="50" align="center" />
        <el-table-column
          prop="secdClassName"
          label="检测类别"
          width="100px"
          align="center"
        />
        <el-table-column prop="factorName" label="检测因子" align="center">
          <template slot-scope="{ row }">
            {{ row.factorName
            }}{{
              row.meanName && row.meanName.length > 0
                ? "(" + row.meanName + ")"
                : ""
            }}
          </template>
        </el-table-column>
        <el-table-column prop="standardNo" label="标准号" align="center" />
        <el-table-column
          prop="standardName"
          label="标准名称"
          min-width="130px"
          align="center"
        />
        <el-table-column prop="factorPoint" label="检测位置" align="center" />
        <el-table-column prop="frequency" label="频次(次/天)" align="center" />
        <el-table-column prop="dayCount" label="天数" align="center" />
        <el-table-column label="次数" align="center">
          <template slot-scope="{ row }">
            {{ Number(row.dayCount * row.frequency) }}
          </template>
        </el-table-column>
        <el-table-column label="是否分包" align="center">
          <template slot-scope="{ row }">
            <span v-if="row.fbFlag === '1'">是</span>
            <span v-if="row.fbFlag === '0'">否</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog
      :visible.sync="taskFacotyVisible"
      center
      append-to-body
      fullscreen
    >
      <el-card shadow="never">
        <div slot="header" class="clearfix">
          <span>任务检测因子<i class="el-input__icon"/></span>
          <el-button
            style="float: right; margin:4px 2px;"
            type="primary"
            plain
            size="mini"
            @click="addFactor"
            >添加因子</el-button
          >
        </div>
        <el-table :data="offerDisForm.factorTdos" border stripe>
          <el-table-column type="index" width="50" align="center" />
          <el-table-column
            prop="secdClassName"
            label="检测类别"
            width="100px"
            align="center"
          />
          <el-table-column prop="factorName" label="检测因子" align="center">
            <template slot-scope="{ row }">
              {{ row.factorName
              }}{{
                row.meanName && row.meanName.length > 0
                  ? "(" + row.meanName + ")"
                  : ""
              }}
            </template>
          </el-table-column>
          <el-table-column prop="standardNo" label="标准号" align="center" />
          <el-table-column
            prop="standardName"
            label="标准名称"
            min-width="130px"
            align="center"
          />
          <el-table-column prop="factorPoint" label="检测位置" align="center" />
          <el-table-column
            prop="frequency"
            label="频次(次/天)"
            align="center"
          />
          <el-table-column prop="dayCount" label="天数" align="center" />
          <el-table-column label="次数" align="center">
            <template slot-scope="{ row }">
              {{ Number(row.dayCount * row.frequency) }}
            </template>
          </el-table-column>
          <!--          <el-table-column label="是否分包" align="center">-->
          <!--            <template slot-scope="{row}">-->
          <!--              {{ row.fbFlag==='1'?"Y":"N" }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->

          <!--是否分包-->
          <el-table-column prop="fbFlag" label="是否分包" align="center">
            <template slot-scope="{ row }">
              <el-switch
                v-model="row.fbFlag"
                v-if="row.fbFlag != null"
                active-value="0"
                inactive-value="1"
                active-color="#909399ad"
                inactive-color="#ff4949"
                @change="changeSwitch(row.fbFlag, row.judgeOrganId)"
              >
              </el-switch>
            </template>
          </el-table-column>
          <!--分包机构-->
          <el-table-column prop="judgeOrganId" label="分包机构" align="center">
            <template slot-scope="{ row }">
              <div>
                <!--是分包-->
                <el-select
                  v-model="row.judgeOrganId"
                  v-if="row.fbFlag === '1'"
                  placeholder="机构选择"
                  style="width: 102px"
                >
                  <el-option
                    v-for="item in scheduleJudgeArrayTwo"
                    :key="item.id"
                    :label="item.judgeOrganName"
                    :value="item.id"
                  />
                </el-select>
                <!--不是分包-->
                <el-select
                  v-model="isFbFlag"
                  v-if="row.fbFlag === '0'"
                  :disabled="row.fbFlag === '0'"
                  placeholder="机构选择"
                  style="width: 102px"
                >
                  <el-option
                    v-for="item in scheduleJudgeArrayTwo"
                    :key="item.id"
                    :label="item.judgeOrganName"
                    :value="item.id"
                  />
                </el-select>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="factorRemark"
            label="因子备注"
            :show-overflow-tooltip="true"
            align="center"
          />
          <el-table-column label="操作" align="center">
            <template slot-scope="{ $index }">
              <el-button type="text" @click="delFactor($index)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button type="warning" style="width: 90px;" @click="handleNavStep"
          >上一步</el-button
        >
        <el-button
          type=""
          style="width: 90px;"
          @click="taskFacotyVisible = false"
          >取 消</el-button
        >
        <el-button type="info" style="width: 90px;" @click="handlePlanSave"
          >保 存</el-button
        >
        <el-button
          type="primary"
          style="width: 90px;"
          @click="handlePlanConfirm"
          >确 认</el-button
        >
      </div>
    </el-dialog>
    <el-dialog
      :visible.sync="factorVisible"
      append-to-body
      width="85%"
      :close-on-click-modal="false"
      top="5vh"
    >
      <factor-chose-list
        :clear-type="cleanAttr"
        @handleCancel="getTabStatus"
        @handleConfim="getResultForAdd"
      />
      <!-- <div slot="footer" class="dialog-footer">
        <el-button @click="factorVisible=false">取 消</el-button>
        <el-button type="primary" @click="confirmChoseFactor">确 认</el-button>
      </div> -->
    </el-dialog>

    <!-- 计划列表 -->
    <el-dialog
      :visible.sync="planInfoVisibleOne"
      :title="titlePlan"
      append-to-body
      fullscreen
      :close-on-click-modal="false"
    >
      <el-form :model="planFormOne" inline>
        <el-row>
          <el-col :span="6">
            <el-form-item label="计划名称:">
              <el-input v-model="planFormOne.planName" placeholder="计划名称" />
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item>
              <span slot="label">
                选择监测频次
                <el-popover
                  placement="top-start"
                  title=""
                  width="300"
                  trigger="hover"
                  content="监测计划的频次"
                >
                  <svg-icon
                    slot="reference"
                    icon-class="help"
                    style="font-size:16px"
                  />
                </el-popover>
                :
              </span>
              <el-select
                v-model="planFormOne.checkFreq"
                placeholder="选择监测频次"
                @change="reflushTimeOne"
              >
                <el-option
                  v-for="item in checkFreqArrayOne"
                  :key="item.desc"
                  :label="item.desc"
                  :value="item.desc"
                />
              </el-select>
            </el-form-item>
            <el-form-item>
              <span slot="label">
                计划执行次数
                <el-popover
                  placement="top-start"
                  title=""
                  width="300"
                  trigger="hover"
                  content="该监测计划一共需要执行的总次数"
                >
                  <svg-icon
                    slot="reference"
                    icon-class="help"
                    style="font-size:16px"
                  />
                </el-popover>
                :
              </span>
              <el-input-number
                v-model="planFormOne.execTimes"
                :min="0"
                :step="1"
                :precision="0"
                :disabled="planFormOne.checkFreq === '单次'"
                controls-position="right"
                placeholder="计划执行次数"
                @change="reflushTimeOne"
              />
            </el-form-item>
            <el-form-item
              v-show="planFormOne.planTime.length > 0"
              label="计划时长:"
            >
              {{ planFormOne.planTime }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-card shadow="never" style="width: 100%; min-height: 500px">
        <el-button
          v-if="this.operEditType === true"
          style="float: right; margin:4px 2px;margin-top: -15px;"
          type="primary"
          size="mini"
          @click="restoresInitialsPlan"
          >恢复初始计划</el-button
        >
        <div slot="header" class="clearfix">
          <span>检测因子信息<i class="el-input__icon"/></span>
          <el-button
            style="float: right; margin:4px 2px;"
            type="primary"
            plain
            size="mini"
            @click="choseGroup"
            >选择因子套餐</el-button
          >
          <el-button
            style="float: right; margin:4px 2px;"
            type="primary"
            plain
            size="mini"
            @click="addFactorOne"
            >添加因子</el-button
          >
        </div>
        <el-table
          :data="planFormOne.factorTdoList"
          stripe
          border
          highlight-current-row
          :header-cell-style="{ background: '#ECF3FC' }"
          max-height="700px"
        >
          <template slot="empty">
            <div class="table_empty">
              <div class="empty_tips">
                <span>
                  暂无因子
                </span>
              </div>
            </div>
          </template>
          <el-table-column
            prop="factorPoint"
            label="检测位置"
            min-width="110"
            align="center"
          >
            <template slot-scope="{ row }">
              <el-input v-model="row.factorPoint" placeholder="请录入位置" />
            </template>
          </el-table-column>
          <el-table-column prop="className" label="检测对象" align="center" />
          <el-table-column prop="secdClassName" label="检测类别" align="center">
            <template slot-scope="{ row }">
              <template v-if="row.meanName && row.meanName.length > 0">
                {{ row.secdClassName
                }}<span style="color:red">{{ "(" + row.meanName + ")" }}</span>
              </template>
              <template v-else>
                {{ row.secdClassName }}
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="factorName" label="检测因子" align="center" />
          <el-table-column
            prop="standardNo"
            label="标准号"
            min-width="110px"
            align="center"
          />
          <el-table-column
            prop="standardName"
            label="标准名称"
            min-width="150px"
            align="center"
          />
          <el-table-column prop="dayCount" width="100px" align="center">
            <template slot="header">
              天数 <i class="el-input__icon " />
              <el-popover
                placement="top-start"
                title=""
                width="300"
                trigger="hover"
                content="该检测因子需要采集的天数"
              >
                <svg-icon
                  slot="reference"
                  icon-class="help"
                  style="font-size:16px"
                />
              </el-popover>
            </template>
            <template slot-scope="{ row }">
              <el-input-number
                v-model="row.dayCount"
                size="small"
                style="width: 100%;"
                :disabled="
                  row.secdClassId === '002001' || row.secdClassId === '002003'
                "
                :min="1"
                :step="1"
                :precision="0"
                controls-position="right"
                @change="reflushMoney(row)"
              />
            </template>
          </el-table-column>
          <el-table-column prop="frequency" width="120px" align="center">
            <template slot="header">
              频次(次/天) <i class="el-input__icon " />
              <el-popover
                placement="top-start"
                title=""
                width="300"
                trigger="hover"
                content="该检测因子每天需要采集的次数"
              >
                <svg-icon
                  slot="reference"
                  icon-class="help"
                  style="font-size:16px"
                />
              </el-popover>
            </template>
            <template slot-scope="{ row }">
              <el-input-number
                v-model="row.frequency"
                size="small"
                style="width: 100%;"
                :disabled="
                  row.secdClassId === '002001' || row.secdClassId === '002003'
                "
                :min="1"
                :step="1"
                :max="
                  row.secdClassId === '004001' ||
                  row.secdClassId === '004002' ||
                  row.secdClassId === '004003' ||
                  row.secdClassId === '004004' ||
                  row.secdClassId === '004005'
                    ? 0
                    : 10
                "
                :precision="0"
                controls-position="right"
                @change="reflushMoney(row)"
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="totalNum"
            label="次数"
            width="100px"
            align="center"
          >
            <template slot-scope="{ row }">
              {{ Number(row.frequency * row.dayCount) }}
            </template>
          </el-table-column>

          <!--是否分包-->
          <el-table-column prop="fbFlag" label="是否分包" align="center">
            <template slot-scope="{ row }">
              <el-switch
                v-model="row.fbFlag"
                v-if="row.fbFlag != null"
                active-value="0"
                inactive-value="1"
                active-color="#909399ad"
                inactive-color="#ff4949"
                @change="changeSwitch(row.fbFlag, row.judgeOrganId)"
              >
              </el-switch>
            </template>
          </el-table-column>

          <!--分包机构-->
          <el-table-column prop="judgeOrganId" label="分包机构" align="center">
            <template slot-scope="{ row }">
              <div>
                <!--是分包-->
                <el-select
                  v-model="row.judgeOrganId"
                  v-if="row.fbFlag === '1'"
                  placeholder="机构选择"
                  style="width: 102px"
                >
                  <el-option
                    v-for="item in scheduleJudgeArrayTwo"
                    :key="item.id"
                    :label="item.judgeOrganName"
                    :value="item.id"
                  />
                </el-select>
                <!--不是分包-->
                <el-select
                  v-model="isFbFlag"
                  v-if="row.fbFlag === '0'"
                  :disabled="row.fbFlag === '0'"
                  placeholder="机构选择"
                  style="width: 102px"
                >
                  <el-option
                    v-for="item in scheduleJudgeArrayTwo"
                    :key="item.id"
                    :label="item.judgeOrganName"
                    :value="item.id"
                  />
                </el-select>
              </div>
            </template>
          </el-table-column>
          <!--          <el-table-column prop="costPerTime" label="单次费用（元）" width="120px" align="center">-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-input-number v-model="row.costPerTime" size="small" controls-position="right" :min="0.01" style="width: 100%;" @change="reflushMoney(row)" />-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column prop="totalCost" label="总计（元）" width="120px" align="center">-->
          <!--            <template slot-scope="{row}">-->
          <!--              {{ parseFloat(row.frequency * row.dayCount * row.costPerTime).toFixed(2) }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column align="center" label="操作">
            <template slot-scope="{ $index, row }">
              <el-popover placement="left" width="280" trigger="click">
                <el-input v-model="row.remark" placeholder="录入备注信息" />
                <el-button slot="reference" type="text">备注</el-button>
              </el-popover>
              <el-button
                style="margin-left: 10px;"
                type="text"
                @click="handleRowDel($index, row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button type="" @click="handleCancle">取消</el-button>
        <el-button type="primary" @click="confimPlanInfo">确认</el-button>
      </div>
    </el-dialog>
    <!--添加因子-->
    <el-dialog
      :visible.sync="factorVisibleOne"
      append-to-body
      width="85%"
      :close-on-click-modal="false"
      top="5vh"
    >
      <factor-chose-list
        :clear-type="cleanAttrOne"
        @handleCancel="getTabStatusOne"
        @handleConfim="getResultForAddOne"
      />
    </el-dialog>
    <!--选择因子套餐-->
    <el-dialog
      title="因子套餐"
      :visible.sync="factorGroupVisible"
      append-to-body
      :before-close="handleClearTabs"
      :close-on-click-modal="false"
      width="85%"
    >
      <el-tabs v-model="activeName">
        <el-tab-pane label="同系因子套餐" name="1">
          <same-meal
            :clear-type="cleanAttrOne"
            @handleCancel="getTabStatusTwo"
            @handleConfim="getTabResultForSame"
          />
        </el-tab-pane>
        <el-tab-pane label="自由因子套餐" name="2">
          <free-meal
            :clear-type="cleanAttrOne"
            @handleCancel="getTabStatusTwo"
            @handleConfim="getTabResultForFree"
          />
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination
import FactorChoseList from "@/components/FactorChoseList";
import * as taskServer from "@/api/task";
import * as dictServer from "@/api/dict";
import { validPhone } from "@/utils/validate";
import { uuid } from "vue-uuid";
import freeMeal from "@/views/order/components/freeMeal";
import sameMeal from "@/views/order/components/sameMeal";
import { findScheduleJobId, findScheduleValidList } from '@/api/task'

const TASK_STATUS = {
  "0": "待调度",
  "1": "调度中",
  "2": "调度完成"
};
export default {
  components: { Pagination, FactorChoseList, freeMeal, sameMeal },
  filters: {
    statusQualityFilter(status) {
      const statusMap = {
        "0": "",
        "1": "warning",
        "2": "success"
      };
      return statusMap[status];
    }
  },
  data() {
    const validatePhone = (rule, value, callback) => {
      if (value && value.length > 0) {
        if (validPhone(value)) {
          callback();
        } else {
          callback(new Error("输入正确的电话号码"));
        }
      } else {
        callback();
      }
    };
    return {
      TASK_STATUS,
      searchForm: {
        scheduCircle: "",
        contCode: "",
        projectName: "",
        scheduStatus: "",
        fuzzy: "",
        enableStatus: "1",
        pageNumber: 1,
        pageSize: 10
      },
      total: 0,
      taskData: [],
      taskVisible: false,
      taskForm: {
        projectName: "",
        offerId: "",
        contCode: "",
        consignorName: "",
        consignorLinker: "",
        consignorLinkerPhone: ""
      },
      factorData: [],
      factorTaskData: [],
      planTaskData: [],
      jobSwitch: true,
      offerDisForm: {
        addOrUpdateMent: "",
        checkType:"",
        taskId: "",
        jobId: "",
        projectName: "",
        consignorName: "",
        consignorLinker: "",
        consignorLinkerPhone: "",
        inspectionName: "",
        inspectionLinker: "",
        inspectionLinkerPhone: "",
        startDate: "",
        endDate: "",
        projectAddress: "",
        province: "",
        city: "",
        county: "",
        checkGoal: "",
        jobRemark: "",
        offerId: "",
        factorTdos: []
      },
      OfferDisRules: {
        consignorLinker: [
          { required: true, message: "请录入委托人", trigger: "blur" }
        ],
        consignorLinkerPhone: [
          { required: true, message: "请录入委托人联系方式", trigger: "blur" }
        ],
        inspectionName: [
          { required: true, message: "请录入受检单位", trigger: "blur" }
        ],
        inspectionLinker: [
          { required: true, message: "请录入受检人", trigger: "blur" }
        ],
        // inspectionLinkerPhone: [{ required: true, message: '请录入受检人联系方式', trigger: 'blur' }, { required: true, validator: validatePhone, trigger: 'blur' }],
        inspectionLinkerPhone: [
          { required: true, message: "请录入受检人联系方式", trigger: "blur" }
        ],
        startDate: [
          { required: true, message: "请选择开始时间", trigger: "blur" }
        ],
        endDate: [
          { required: true, message: "请选择结束时间", trigger: "blur" }
        ],
        projectAddress: [
          { required: true, message: "地址信息不能为空", trigger: "blur" }
        ],
        jobId: [
          { required: true, message: "任务单号不能为空", trigger: "change" }
        ]
      },
      provinceArray: [],
      cityArray: [],
      areaArray: [],
      currentRow: {},
      taskTitle: "",
      taskSedVisible: false,
      multipleSelection: [],
      planFactorVisible: false,
      planFactorDetails: [], // 因子列表-详情查看
      taskFacotyVisible: false,
      // 添加因子
      currentUUid: "",
      cleanAttr: "",
      choseFatcors: [],
      factorVisible: false,
      currentJobId: "",

      planInfoVisibleOne: false,
      planFormOne: {
        planName: "",
        checkFreq: "",
        execTimes: 0,
        planTime: "",
        scheduleTimes: "",
        checkFactorCnt: 0,
        checkFee: "",
        factorTdoList: []
      },
      checkFreqArrayOne: [],
      startFactorGroup: "",
      groupAddressArray: [],
      multiplGroupeSelection: [],
      choseGroupFatcors: [], // 套餐因子选择
      factorGroupVisible: false,
      activeName: "1",
      currentUUidOne: "",
      cleanAttrOne: "",
      factorVisibleOne: false,
      orderFormOne: {
        offerId: "",
        offerPlanId: null,
        offerPlanTdos: []
      },
      dispatchOfferId: "",
      taskIdOne: "",
      titleOne: "创建新任务",
      titlePlan: "新增计划",
      operEditType: false,
      currentRowOne: {},
      orderFormTwo: {
        planName: null,
        checkFreq: null,
        scheduleTimes: null,
        execTimes: null,
        planTime: null,
        checkFactorCnt: null,
        checkFee: null
      },
      scheduleJudgeArrayTwo: [],
      isFbFlag: null,

      clearData: false
    };
  },
  created() {
    this.getProvince();
    this.handleSearch();
    this.getFreqList();
    this.getScheduleCom();
  },
  methods: {
    getProvince() {
      dictServer.getFirstLevel().then(res => {
        this.provinceArray = res.result;
      });
    },
    getSubRegionByRegionCode(type, regionCode) {
      if (regionCode === "cityArray") {
        this.offerDisForm.city = "";
        this.offerDisForm.county = "";
      } else {
        this.offerDisForm.county = "";
      }
      this.getRegionCode(type, regionCode);
    },
    getRegionCode(type, regionCode) {
      dictServer.getSubRegionByRegionCode(regionCode).then(res => {
        this[type] = res.result;
      });
    },
    handleSearch() {
      taskServer.findByCondition(this.searchForm).then(res => {
        this.taskData = res.result.records || [];
        this.total = res.result.total;
      });
    },
    handleDetail(row) {
      this.$router.push(`/other/orderReportTaskList/${row.taskId}`);
    },

    // 暂停调度任务
    stopsSchedulesTasks(taskId) {
      this.$confirm("确定暂停项目吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const data = { taskId: taskId };
          taskServer.stopsSchedulesTask(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },

    // 删除调度任务
    deletesSchedulesTasks(taskId) {
      this.$confirm(
        "项目删除后，该项目内的所有任务（含已完成和未完成）的采样信息、检测信息、检测报告，以及该项目对应的报价单、合同都会被全部删除。\n" +
          "是否继续?",
        "谨慎操作",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(() => {
          const data = { taskId: taskId };
          taskServer.deletesSchedulesTask(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },

    // 启用、暂停调度计划
    enablesOrStopssOfferPlan(offerPlanId, stateFlag) {
      let titles = "";
      if (stateFlag === true) {
        titles = "开启";
      } else {
        titles = "暂停";
      }
      this.$confirm("确定" + titles + "项目吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const data = { offerPlanId: offerPlanId, stateFlag: stateFlag };
          taskServer.enablesOrStopsOfferPlan(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.findPlanInfos(this.offerDisForm.taskId, null);
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },

    // 删除监测计划
    deleteOfferPlans(offerPlanId) {
      this.$confirm("确定删除计划吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const data = { offerPlanId: offerPlanId };
          taskServer.deleteOfferPlan(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.findPlanInfos(this.offerDisForm.taskId, null);
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },

    doProcessData(data) {
      const parentArray = [];
      if (data.length > 0) {
        const factMap = new Map();
        data.forEach(i => {
          const o = parentArray.find(
            j => j.secdClassName === i.secdClassName && j.fbFlag === i.fbFlag
          );
          if (!o) {
            parentArray.push({
              secdClassName: i.secdClassName,
              fbFlag: i.fbFlag,
              factList: []
            });
          }
          if (factMap.get(i.secdClassName + "-" + i.fbFlag)) {
            const ls = factMap.get(i.secdClassName + "-" + i.fbFlag);
            ls.push(i);
          } else {
            const li = [];
            li.push(i);
            factMap.set(i.secdClassName + "-" + i.fbFlag, li);
          }
        });
        if (parentArray) {
          parentArray.forEach(e => {
            const flist = factMap.get(e.secdClassName + "-" + e.fbFlag);
            const nList = [];
            if (flist) {
              flist.forEach(j => {
                const n = nList.find(x => {
                  if (
                    x.factorPoint === j.factorPoint &&
                    x.frequency === j.frequency &&
                    x.dayCount === j.dayCount
                  ) {
                    if (x.showFactName === "") {
                      x.showFactName = j.factorName;
                    } else {
                      x.showFactName = x.showFactName + "," + j.factorName;
                    }
                    return x;
                  } else {
                    return null;
                  }
                });
                if (!n) {
                  this.$set(j, "showFactName", j.factorName);
                  this.$set(j, "fbFlag", e.fbFlag);
                  nList.push(j);
                }
              });

              e.factList = nList.sort((a, b) =>
                a.checkStandardId > b.checkStandardId
                  ? -1
                  : a.checkStandardId < b.checkStandardId
                  ? 1
                  : 0
              );
            }
          });
        }
      }
      return parentArray;
    },
    handleScheduler(row) {
      // 获取地区信息
      if (row.province) {
        this.getRegionCode("cityArray", row.province);
      }
      if (row.city) {
        this.getRegionCode("areaArray", row.city);
      }

      this.dispatchOfferId = row.offerId;
      this.titleOne = "创建新任务";
      this.titlePlan = "修改计划";
      this.currentRow = row;
      this.changeJobSwitch();
      this.clearForm();
      this.offerDisForm.taskId = row.taskId;
      this.offerDisForm.checkType  = row.checkType ;
      this.offerDisForm.consignorName = row.consignorName;
      this.offerDisForm.consignorLinker = row.consignorLinker;
      this.offerDisForm.consignorLinkerPhone = row.consignorLinkerPhone;
      this.offerDisForm.inspectionName = row.consignorName;
      this.offerDisForm.inspectionLinker = row.consignorLinker;
      this.offerDisForm.inspectionLinkerPhone = row.consignorLinkerPhone;
      this.offerDisForm.jobId = row.jobId;
      this.offerDisForm.projectName = row.projectName;

      this.offerDisForm.province = row.province;
      this.offerDisForm.city = row.city;
      this.offerDisForm.county = row.county;
      this.offerDisForm.projectAddress = row.projectAddress;
      this.offerDisForm.addOrUpdateMent = "1"
      if (row.checkType == 1) {
        this.offerDisForm.checkGoal = "为客户了解样品中的污染物提供检测数据。";
      }else{
        this.offerDisForm.checkGoal = "";
      }
      this.findPlanInfos(row.taskId, 1);
    },
    handleUpdateScheduler(row) {
      this.dispatchOfferId = row.offerId;
      this.titleOne = "编辑新任务";
      this.titlePlan = "修改计划";
      this.currentRow = row;
      this.clearForm();
      // 获取任务对象
      taskServer.findJobByTaskId(row.taskId).then(res => {
        this.currentJobId = res.result.jobId || "";
        this.offerDisForm = res.result || {};
        this.offerDisForm.projectName = row.projectName;
        this.offerDisForm.taskId = row.taskId;
        this.offerDisForm.consignorName = row.consignorName;
        this.offerDisForm.addOrUpdateMent = "2"
        // 获取地区信息
        if (this.offerDisForm.province) {
          this.getRegionCode("cityArray", this.offerDisForm.province);
        }
        if (this.offerDisForm.city) {
          this.getRegionCode("areaArray", this.offerDisForm.city);
        }
        this.findPlanInfos(row.taskId, 2);
      });
    },
    findPlanInfos(taskId, type) {
      // 计划列表
      taskServer.findOfferPlanByTaskId(taskId).then(result => {
        if (result.code === 200) {
          this.planTaskData = result.result || [];
          if (
            this.offerDisForm.offerPlanIds &&
            this.offerDisForm.offerPlanIds.length > 0
          ) {
            result.result.forEach(i => {
              if (this.offerDisForm.offerPlanIds.includes(i.offerPlanId)) {
                this.multipleSelection.push(i);
              }
            });
            this.multipleSelection.forEach(j => {
              this.$nextTick(() => {
                this.$refs.multipleTable.toggleRowSelection(j);
              });
            });
          }
          this.taskSedVisible = true;
        }
      });
    },
    findPlanInfosTwo(taskId, type) {
      // 计划列表
      taskServer.findOfferPlanByTaskId(taskId).then(result => {
        if (result.code === 200) {
          this.planTaskData = result.result || [];
          if (
            this.offerDisForm.offerPlanIds &&
            this.offerDisForm.offerPlanIds.length > 0
          ) {
            result.result.forEach(i => {
              if (this.offerDisForm.offerPlanIds.includes(i.offerPlanId)) {
                this.multipleSelection.push(i);
              }
            });
            this.multipleSelection.forEach(j => {
              this.$nextTick(() => {
                this.$refs.multipleTable.toggleRowSelection(j);
              });
            });
          }
          this.planInfoVisibleOne = true;
        }
      });
    },
    getTaskInfo(dispatchTaskId) {
      taskServer.getLastScheduInfoByTaskId(dispatchTaskId).then(res => {
        if (res.code === 200 && res.result) {
          this.offerDisForm = res.result;
          // 获取 市区字典列表信息
          this.getSubRegionByRegionCode("cityArray", res.result.province);
          this.getSubRegionByRegionCode("areaArray", res.result.city);
          this.taskSedVisible = true;
        }
      });
      taskServer.getOfferFactorByTaskId(dispatchTaskId).then(result => {
        if (result.code === 200) {
          this.factorTaskData = result.result || [];
          this.taskSedVisible = true;
        }
      });
    },
    confirmDialog() {
      if (
        this.offerDisForm.province &&
        this.offerDisForm.city &&
        this.offerDisForm.county
      ) {
        this.$refs.offerDisForm.validate(valid => {
          if (valid) {
            taskServer.doScheduTask(this.offerDisForm).then(result => {
              if (result.code === 200) {
                this.$notify({
                  title: "成功",
                  message: result.message,
                  type: "success"
                });
                this.handleSearch();
                this.taskSedVisible = false;
              } else {
                this.$notify({
                  title: "失败",
                  message: result.message,
                  type: "error"
                });
              }
            });
          } else {
            this.$message.warning("请完善信息后提交");
          }
        });
      } else {
        this.$message.warning("省、市、区信息不能为空");
      }
    },
    handleSelectionChange(val) {
      this.clearData = true;
      this.multipleSelection = val;
    },
    handleNavStep() {
      this.clearData = false;
      this.taskFacotyVisible = false;
    },
    handlePreStep() {
      if (this.offerDisForm.endDate < this.offerDisForm.startDate) {
        this.$message.warning("结束时间不能早于开始时间!");
        return;
      }
      // 处于编辑状态
      if (this.clearData) {
        if (this.currentJobId !== "") {
          taskServer.findJobFactorsById(this.currentJobId).then(res => {
            this.offerDisForm.factorTdos = res.result || [];
            this.taskFacotyVisible = true;
          });
        } else {
          if (this.multipleSelection.length >= 1) {
            const planIds = this.multipleSelection.map(i => i.offerPlanId);
            taskServer
              .findFactorsByOfferPlanIds({ offerPlanId: planIds.toString() })
              .then(res => {
                this.offerDisForm.factorTdos =
                  res.result.map(i => {
                    this.$set(i, "factorRemark", i.remark);
                    return i;
                  }) || [];
                this.taskFacotyVisible = true;
              });
          } else {
            this.$message.warning("至少选择一个计划信息!");
          }
        }
      } else {
        this.taskFacotyVisible = true;
      }
    },
    checkPlanDetail(row) {
      taskServer.findFactorsByPlanId(row.offerPlanId).then(res => {
        this.planFactorDetails = res.result || [];
      });
      this.planFactorVisible = true;
    },
    delFactor(index) {
      this.offerDisForm.factorTdos.splice(index, 1);
    },
    handlePlanSave() {
      // 任务分配保存
      if (this.offerDisForm.factorTdos.length > 0) {
        for (let i = 0; i < this.offerDisForm.factorTdos.length; i++) {
          if (this.offerDisForm.factorTdos[i].fbFlag === "1") {
            if (this.offerDisForm.factorTdos[i].judgeOrganId === null) {
              this.$message.error("请选择机构");
              return;
            }
          }
        }
      }
      taskServer.saveScheduleJob(this.offerDisForm).then(result => {
        if (result.code === 200) {
          this.$notify({
            title: "成功",
            message: result.message,
            type: "success"
          });
          this.handleSearch();
          this.taskSedVisible = false;
          this.taskFacotyVisible = false;
        } else {
          this.$notify({
            title: "失败",
            message: result.message,
            type: "error"
          });
        }
      });
      // if (this.offerDisForm.province &&
      //    this.offerDisForm.city &&
      //    this.offerDisForm.county) {
      //   this.$refs.offerDisForm.validate(valid => {
      //     if (valid) {
      //       taskServer.saveScheduleJob(this.offerDisForm).then(result => {
      //         if (result.code === 200) {
      //           this.$notify({
      //             title: '成功',
      //             message: result.message,
      //             type: 'success'
      //           })
      //           this.handleSearch()
      //           this.taskSedVisible = false
      //           this.taskFacotyVisible = false
      //         } else {
      //           this.$notify({
      //             title: '失败',
      //             message: result.message,
      //             type: 'error'
      //           })
      //         }
      //       })
      //     } else {
      //       this.$message.warning('请完善信息后提交')
      //     }
      //   })
      // } else {
      //   this.$message.warning('省、市、区信息不能为空')
      // }
    },
    handlePlanConfirm() {
      if (this.offerDisForm.factorTdos.length > 0) {
        for (let i = 0; i < this.offerDisForm.factorTdos.length; i++) {
          if (this.offerDisForm.factorTdos[i].fbFlag === "1") {
            if (this.offerDisForm.factorTdos[i].judgeOrganId === null) {
              this.$message.error("请选择机构");
              return;
            }
          }
        }
      }
      if (
        this.offerDisForm.province &&
        this.offerDisForm.city &&
        this.offerDisForm.county
      ) {
        this.$refs.offerDisForm.validate(valid => {
          if (valid) {
            taskServer.confirmScheduleJob(this.offerDisForm).then(result => {
              if (result.code === 200) {
                this.$notify({
                  title: "成功",
                  message: result.message,
                  type: "success"
                });
                this.handleSearch();
                this.taskSedVisible = false;
                this.taskFacotyVisible = false;
              } else {
                this.$notify({
                  title: "失败",
                  message: result.message,
                  type: "error"
                });
              }
            });
          } else {
            this.$message.warning("请完善信息后提交");
          }
        });
      } else {
        this.$message.warning("省、市、区信息不能为空");
      }
    },
    addFactor() {
      // 获取UUID
      this.cleanAttr = uuid.v4().replaceAll("-", "");
      this.factorVisible = true;
    },

    getTabStatus(val) {
      if (!val) {
        this.factorVisible = false;
      }
    },
    getResultForAdd(val) {
      this.offerDisForm.factorTdos = this.offerDisForm.factorTdos.concat(val);
      this.factorVisible = false;
    },
    confirmChoseFactor() {},
    clearForm() {
      this.currentJobId = "";
      this.offerDisForm = {
        taskId: "",
        jobId: "",
        projectName: "",
        consignorName: "",
        consignorLinker: "",
        consignorLinkerPhone: "",
        inspectionName: "",
        inspectionLinker: "",
        inspectionLinkerPhone: "",
        startDate: "",
        endDate: "",
        projectAddress: "",
        province: "",
        city: "",
        county: "",
        checkGoal: "",
        jobRemark: "",
        factorTdos: []
      };
    },

    // 新逻辑
    addPlanInfoOne(row) {
      this.titlePlan = "新增计划";
      this.dispatchOfferId = row.offerId;
      this.taskIdOne = row.taskId;
      this.planFormOne = {
        planName: "",
        checkFreq: "",
        execTimes: 0,
        planTime: "",
        checkFactorCnt: 0,
        checkFee: "",
        factorTdoList: []
      };
      this.operEditType = false;
      this.planInfoVisibleOne = true;
    },
    reflushTimeOne() {
      // 根据不同类型计算计划时长 TODO
      if (this.planFormOne.checkFreq === "单次") {
        this.planFormOne.planTime = 1;
        this.planFormOne.scheduleTimes = 1;
        this.planFormOne.execTimes = 1;
      } else {
        if (this.planFormOne.execTimes > 0) {
          const choseObj = this.checkFreqArrayOne.find(
            i => i.desc === this.planFormOne.checkFreq
          );
          if (choseObj) {
            debugger;
            this.planFormOne.planTime =
              Number(
                (choseObj.calBaseVal * this.planFormOne.execTimes) /
                  choseObj.calVal
              ).toFixed(1) +
              "  " +
              (choseObj.unit === "none" ? "" : choseObj.unit);
            this.planFormOne.scheduleTimes = Number(
              choseObj.calVal * this.planFormOne.execTimes
            ).toFixed(0);
          }
        }
      }
    },
    choseGroup() {
      this.currentUUidOne = uuid.v4().replaceAll("-", "");
      this.cleanAttrOne = this.currentUUidOne; // 清空弹窗信息的动态触发判定
      this.startFactorGroup = "";
      this.groupAddressArray = [];
      this.multiplGroupeSelection = [];
      this.choseGroupFatcors = [];
      this.factorGroupVisible = true;
    },
    getPlanSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map(item => {
          if (column.label === "次数") {
            return Number(item.dayCount * item.frequency);
          } else if (column.label === "总计") {
            return parseFloat(
              item.dayCount * item.frequency * item.costPerTime
            );
          } else {
            return Number(item[column.property]);
          }
        });
        if (!values.every(value => isNaN(value))) {
          if (index === 6) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
          } else if (index === 8) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
          } else if (index === 10) {
            sums[index] = values
              .reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                  return prev + curr;
                } else {
                  return prev;
                }
              }, 0)
              .toFixed(2);
          }
        } else {
          sums[index] = "";
        }
      });
      return sums;
    },
    reflushMoney(row) {
      row.totalNum = Number(row.dayCount * row.frequency);
      row.totalCost = Number(
        row.dayCount * row.frequency * row.costPerTime
      ).toFixed(2);
    },
    handleClearTabs(done) {
      // 数据清空处理
      this.$confirm("确认关闭？")
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    getTabResultForFree(val) {
      // 自由套餐数据获取
      this.$nextTick(() => {
        if (
          this.planFormOne.factorTdoList &&
          this.planFormOne.factorTdoList.length > 0
        ) {
          this.planFormOne.factorTdoList = this.planFormOne.factorTdoList.concat(
            val
          );
        } else {
          this.planFormOne.factorTdoList = val;
        }
      });
      this.factorGroupVisible = false;
      console.log("自由套餐：" + val);
    },
    getTabResultForSame(val) {
      // 同系套餐数据获取
      this.$nextTick(() => {
        if (
          this.planFormOne.factorTdoList &&
          this.planFormOne.factorTdoList.length > 0
        ) {
          this.planFormOne.factorTdoList = this.planFormOne.factorTdoList.concat(
            val
          );
        } else {
          this.planFormOne.factorTdoList = val;
        }
      });
      this.factorGroupVisible = false;
    },
    handleRowDel(index, row) {
      this.planFormOne.factorTdoList.splice(index, 1);
    },
    handleCancle() {
      this.planInfoVisibleOne = false;
    },
    addFactorOne() {
      // 获取UUID
      this.cleanAttrOne = uuid.v4().replaceAll("-", "");
      this.factorVisibleOne = true;
    },
    getResultForAddOne(val) {
      this.planFormOne.factorTdoList = this.planFormOne.factorTdoList.concat(
        val
      );
      this.factorVisibleOne = false;
    },
    confimPlanInfo() {
      // 新增计划
      if (
        !this.planFormOne.factorTdoList ||
        this.planFormOne.factorTdoList.length === 0
      ) {
        this.$message.error("因子信息不能为空");
        return;
      }
      for (let i = 0; i < this.planFormOne.factorTdoList.length; i++) {
        if (this.planFormOne.factorTdoList[i].fbFlag === "1") {
          if (this.planFormOne.factorTdoList[i].judgeOrganId === null) {
            this.$message.error("请选择机构");
            return;
          }
        }
      }
      if (this.planFormOne.execTimes <= 0) {
        this.$message.error("计划执行次数不能小于1！");
        return;
      }
      var totalPriceInfo = 0;
      var totalCount = 0;
      var checkFactors = [];
      var checkFactorNames = [];
      var factorList = this.planFormOne.factorTdoList.map(m => {
        totalPriceInfo =
          parseFloat(totalPriceInfo) +
          parseFloat(m.frequency * m.dayCount * m.costPerTime);
        totalCount =
          parseFloat(totalCount) + parseFloat(m.frequency * m.dayCount);
        const item = {
          checkStandardId: m.checkStandardId
            ? m.checkStandardId
            : m.standardCode,
          isFactor: m.isFactor,
          factorName: m.factorName,
          secdClassId: m.secdClassId,
          frequency: m.frequency,
          dayCount: m.dayCount,
          factorGroupKey: m.factorGroupKey,
          costPerTime: m.costPerTime,
          factorPoint: m.factorPoint.trim(),
          standardNo: m.standardNo,
          dynamicParam: m.dynamicParam,
          remark: m.remark,
          secdClassName: m.secdClassName,
          meanName: m.meanName,
          totalCost: m.totalCost,
          standardName: m.standardName,
          totalNum: m.totalNum,
          className: m.className,
          fbFlag: m.fbFlag,
          judgeOrganId: m.judgeOrganId,
          subCheckStandardIds: m.subCheckStandardIds
            ? m.subCheckStandardIds
            : []
        };
        if (m.subCheckStandards) {
          const subCheckStandards = m.subCheckStandards.map(
            j => j.standardCode
          );
          this.$set(item, "subCheckStandardIds", subCheckStandards);
        }

        if (m.fbFlag === "0") {
          const judgeOrganId = null;
          this.$set(item, "judgeOrganId", judgeOrganId);
        }

        // 因子信息校验
        const obj = checkFactors.find(
          i =>
            i.factorPoint === m.factorPoint &&
            i.secdClassName === m.secdClassName &&
            i.factorName === m.factorName &&
            i.standardNo === m.standardNo
        );
        if (!obj) {
          checkFactors.push(m);
        } else {
          checkFactorNames.push(m.factorName);
        }
        return item;
      });

      if (checkFactorNames.length > 0) {
        this.$message.error(
          "在一个监测计划内，同一检测位置、同一检测类别下具有相同标准号的检测因子不能重复添加！"
        );
        return;
      }
      var offerPlan = {
        planName: this.planFormOne.planName,
        checkFreq: this.planFormOne.checkFreq,
        execTimes: this.planFormOne.execTimes,
        planTime: this.planFormOne.planTime,
        scheduleTimes: this.planFormOne.scheduleTimes,
        checkFactorCnt: totalCount,
        checkFee: totalPriceInfo,
        factorTdoList: factorList
      };

      if (this.operEditType) {
        this.currentRowOne.planName = this.planFormOne.planName;
        this.currentRowOne.checkFreq = this.planFormOne.checkFreq;
        this.currentRowOne.execTimes = this.planFormOne.execTimes;
        this.currentRowOne.planTime = this.planFormOne.planTime;
        this.currentRowOne.scheduleTimes = this.planFormOne.scheduleTimes;
        this.currentRowOne.checkFactorCnt = totalCount;
        this.currentRowOne.checkFee = totalPriceInfo;
        this.currentRowOne.factorTdoList = factorList;

        this.orderFormOne.offerId = this.dispatchOfferId;
        this.orderFormOne.offerPlanId = this.currentRowOne.offerPlanId;
        this.orderFormOne.offerPlanTdos.push(this.currentRowOne);
        this.orderFormTwo.planName = this.currentRowOne.planName;
        this.orderFormTwo.checkFreq = this.currentRowOne.checkFreq;
        this.orderFormTwo.execTimes = this.currentRowOne.execTimes;
        this.orderFormTwo.planTime = this.currentRowOne.planTime;
        this.orderFormTwo.scheduleTimes = this.currentRowOne.scheduleTimes;
        this.orderFormTwo.checkFactorCnt = totalCount;
        this.orderFormTwo.checkFee = totalPriceInfo;

        const orderData = { ...this.orderFormOne, ...this.orderFormTwo };
        this.savesOfferssPlan(orderData);
        this.planInfoVisibleOne = false;
        return;
      }

      this.orderFormOne.offerId = this.dispatchOfferId;
      this.orderFormOne.offerPlanId = null;
      this.orderFormOne.offerPlanTdos.push(offerPlan);
      this.savesOfferssPlan(this.orderFormOne);

      this.planInfoVisibleOne = false;
    },
    // 添加计划
    savesOfferssPlan(data) {
      taskServer.savesOffersPlan(data).then(result => {
        if (result.code === 200) {
          this.$notify({
            title: "成功",
            message: result.message,
            type: "success"
          });
          if (this.operEditType === false) {
            // this.findPlanInfosTwo(this.taskIdOne, null);
          } else {
            this.findPlanInfos(this.offerDisForm.taskId, null);
          }
          this.handleSearch();
          this.orderFormOne = {
            offerId: "",
            offerPlanId: null,
            offerPlanTdos: []
          };
        } else {
          this.$notify({
            title: "失败",
            message: result.message,
            type: "error"
          });
        }
      });
    },
    getFreqList() {
      dictServer.findMonitorFreq().then(result => {
        if (result.code === 200) {
          this.checkFreqArrayOne = result.result;
        }
      });
    },
    getTabStatusOne(val) {
      if (!val) {
        this.factorVisibleOne = false;
      }
    },
    getTabStatusTwo(val) {
      if (!val) {
        this.factorGroupVisible = false;
      }
    },

    //开关事件
    changeSwitch(fbFlag, judgeOrganId) {
    },

    //任务单号--开关事件
    changeJobSwitch(item) {
      if (item === false){
        this.offerDisForm.jobId = "";
      }else {
        taskServer.findScheduleJobId().then(res => {
          if (res.code === 200 && res.result) {
            this.offerDisForm.jobId = res.result.jobId
          }
        })
      }
    },

    getScheduleCom() {
      findScheduleValidList().then(res => {
        this.scheduleJudgeArrayTwo = res.result;
      });
    },

    // 恢复调度初始计划
    restoresInitialsPlan() {
      this.$confirm("确定恢复调度初始计划吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const data = { offerPlanId: this.currentRowOne.offerPlanId };
          taskServer.restoresInitialPlans(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.findPlanInfos(this.offerDisForm.taskId, null);
              this.handleSearch();
              this.planInfoVisibleOne = false;
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },
    // 因子详情、同系物因子套餐详情存进备份表(备份)
    savesRestoreInitialsPlans(data) {
      taskServer.savesRestoreInitialsPlan(data).then(result => {});
    },
    plansUpdate(row) {
      // 计划因子修改
      const dataOne = { offerPlanId: row.offerPlanId };
      this.savesRestoreInitialsPlans(dataOne);
      this.currentRowOne = row;
      this.operEditType = true;
      this.planFormOne = {
        planName: "",
        checkFreq: "",
        execTimes: 0,
        planTime: "",
        checkFactorCnt: 0,
        checkFee: "",
        factorTdoList: []
      };
      this.planFormOne = Object.assign({}, row);
      this.planFormOne.factorTdoList = [...row.factorTdoList];
      this.planInfoVisibleOne = true;
    },

    checkSelectable(item) {
      if (item.scheduledTimes >= item.scheduleTimes) {
        return false;
      }
      if (item.enableStatus === "2") {
        return false;
      }
      return true;
    }
  }
};
</script>

<style scoped lang="scss" type="text/scss">
.search_div {
  >div {
    &:nth-child(1){
      margin-right: 10px;
    }
    display: inline-block;
  }
}

.search_input {
  width: 200px;
  margin-bottom: 5px;
}
.search-right {
  text-align: right;
  padding-right: 25px;
}
.item {
  font-size: 16px;
}
::v-deep .el-card .el-card__header {
  padding: 5px 20px;
  background: #F3F2F2;
}
.block-flex {
  position: relative;
  display: flex;
  &>div{
    border: 1px solid #B7B7B7;
    width: 100px;
    margin: 0;
    line-height: 30px;
    text-align: center;
  }
  &>div:first-child {
    background: #B7B7B7;
  }
}
.card-left {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.card-right {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.el-card {
  overflow: auto;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
.el-icon-arrow-down {
  font-size: 14px;
}
// /deep/.main-body .el-table__header-wrapper  .el-checkbox{
//   display:none
// }
.agreement_picture {
  min-height: calc(100%);
  .pdf{
    height: calc(100%);
  }
}

/deep/ .el-input.is-disabled .el-input__inner {
  color:unset
}

/deep/.i-input .el-input__inner {
  text-align: center;
}
/deep/.right-input .el-input__inner {
  text-align: right;
}

.el-header {
  line-height: 45px;
  height: 45px;
}
.el-footer {
  text-align: right;
  line-height: 45px;
  height: 45px;

  .pagination-container {
    padding: 0;
    margin-top: 10px;
    margin-bottom: 45px;
  }
}
.el-main {
  overflow-y: auto;
}
.el-container {
  max-height: 450px;
}

</style>
<style scoped>
 .text {
   font-size: 14px;
 }
.dialog-item {
  padding-left: 3px;
  line-height: 30px;
  cursor:pointer;

}
.dialog-item:hover {
  background: #e8f4ff;
  border-radius: 3px;
}

table {
  background-color: transparent
}

caption {
  padding-top: 8px;
  padding-bottom: 8px;
  color: #777;
  text-align: left
}

th {
  text-align: left
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px
}

.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: middle;
  border-top: 1px solid #ddd
}

.table>thead>tr>th {
  vertical-align: bottom;
  border-bottom: 2px solid #ddd
}

.table>caption+thead>tr:first-child>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th {
  border-left: 1px solid #F1F2F4
}

.table>tbody+tbody {
  border-top: 2px solid #ddd
}

.table .table {
  background-color: #fff
}

.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th {
  padding: 5px
}

.table-bordered {
  border: 1px solid #ddd
}

.table-bordered>tbody>tr>td,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>td,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th {
  border: 1px solid #ddd
}

.table-bordered>thead>tr>td,.table-bordered>thead>tr>th {
  border-bottom-width: 2px
}

.table-striped>tbody>tr:nth-of-type(odd) {
  background-color: #f9f9f9
}

.table-hover>tbody>tr:hover {
  background-color: #f5f5f5
}

table col[class*=col-] {
  position: static;
  display: table-column;
  float: none
}

table td[class*=col-],table th[class*=col-] {
  position: static;
  display: table-cell;
  float: none
}

.table>tbody>tr.active>td,.table>tbody>tr.active>th,.table>tbody>tr>td.active,.table>tbody>tr>th.active,.table>tfoot>tr.active>td,.table>tfoot>tr.active>th,.table>tfoot>tr>td.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>thead>tr.active>th,.table>thead>tr>td.active,.table>thead>tr>th.active {
  background-color: #f5f5f5
}

.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr.active:hover>th,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover {
  background-color: #e8e8e8
}

.table>tbody>tr.success>td,.table>tbody>tr.success>th,.table>tbody>tr>td.success,.table>tbody>tr>th.success,.table>tfoot>tr.success>td,.table>tfoot>tr.success>th,.table>tfoot>tr>td.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>thead>tr.success>th,.table>thead>tr>td.success,.table>thead>tr>th.success {
  background-color: #dff0d8
}

.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover {
  background-color: #d0e9c6
}

.table>tbody>tr.info>td,.table>tbody>tr.info>th,.table>tbody>tr>td.info,.table>tbody>tr>th.info,.table>tfoot>tr.info>td,.table>tfoot>tr.info>th,.table>tfoot>tr>td.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>thead>tr.info>th,.table>thead>tr>td.info,.table>thead>tr>th.info {
  background-color: #d9edf7
}

.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr.info:hover>th,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover {
  background-color: #c4e3f3
}

.table>tbody>tr.warning>td,.table>tbody>tr.warning>th,.table>tbody>tr>td.warning,.table>tbody>tr>th.warning,.table>tfoot>tr.warning>td,.table>tfoot>tr.warning>th,.table>tfoot>tr>td.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>thead>tr.warning>th,.table>thead>tr>td.warning,.table>thead>tr>th.warning {
  background-color: #fcf8e3
}

.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover {
  background-color: #faf2cc
}

.table>tbody>tr.danger>td,.table>tbody>tr.danger>th,.table>tbody>tr>td.danger,.table>tbody>tr>th.danger,.table>tfoot>tr.danger>td,.table>tfoot>tr.danger>th,.table>tfoot>tr>td.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>thead>tr.danger>th,.table>thead>tr>td.danger,.table>thead>tr>th.danger {
  background-color: #f2dede
}

.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover {
  background-color: #ebcccc
}

.table-responsive {
  min-height: 3.01%;
  overflow-x: auto;
}

.table-bordered, .table-bordered > tbody > tr > td, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > td, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > thead > tr > th {
  border: 1px solid #e9ecef;
  text-align: center;
  line-height: 14px;
}

.table-bordered, td, th {
  border-radius: 0 !important;
}

.table-bordered > tbody > tr:last-child > td {
  border-bottom: 1px solid #e9ecef;
}

.bootstrap-table .fixed-table-container .fixed-table-header {
  overflow: hidden;
  background: rgba(0, 0, 0, .05);
}

.fixed-table-header .table > thead > tr {
  background: none !important;
}

.table > thead > tr {
  color: #636363;
  font-weight: 400;
  background: rgba(0, 0, 0, .05);
  /*   background: repeat-x #fafafa;
background-image: -webkit-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
background-image: -o-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
background-image: linear-gradient(to bottom,#F8F8F8 0,#fafafa 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8f8f8', endColorstr='#ffececec', GradientType=0); */
}

.table > thead > tr > th {
  border-color: #e9ecef;
  font-weight: 700;
  border-right-color: transparent;
}

.table > thead > tr > th .ace-icon:first-child {
  margin-right: 2px;
}

.table > thead > tr > th:first-child {
  border-left-color: #F1F1F1;
}

.table > thead > tr > th:last-child {
  border-right-color: #F1F1F1;
}

.table.table-bordered > thead > tr > th {
  vertical-align: middle;
}

td.center, th.center {
  text-align: center;
}

td .lbl, th .lbl {
  margin-bottom: 0;
}

td .lbl:only-child, th .lbl:only-child {
  vertical-align: top;
}

.table-header {
  background-color: #307ECC;
  color: #FFF;
  font-size: 14px;
  line-height: 38px;
  padding-left: 12px;
  margin-bottom: 1px;
}

.table-header .close {
  margin-right: 8px;
  margin-top: 0;
  opacity: .45;
  filter: alpha(opacity=45);
}

.table-header .close:hover {
  opacity: .75;
  filter: alpha(opacity=75);
}

th.detail-col {
  width: 48px;
  text-align: center;
}

tr.detail-row {
  display: none;
}

tr.detail-row.open {
  display: block;
  display: table-row;
}

tr.detail-row > td {
  background-color: #f1f6f8;
  border-top: 3px solid #d1e1ea !important;
}

.table-detail {
  background-color: #fff;
  border: 1px solid #dcebf7;
  width: 100%;
  padding: 12px;
}

.table-detail td > .profile-user-info {
  width: 100%;
}

</style>
